﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using BusinessEntities;
using SQL_Provider;

namespace DataAccess
{
   public class NhanVien_Adapter
    {

        Provider pd;
        public NhanVien_Adapter()
        {
            pd = new Provider();
        }
        public DataTable NhanVien_SelectAll()
        {
            SqlParameter[] para = new SqlParameter[0];
            return pd.Execute_Table("NhanVien_All", para, CommandType.StoredProcedure);


        }
        public int NhanVien_Insert(NhanVien_Info nv_info)
        {
            SqlParameter[] para = new SqlParameter[8];
            para[0] = new SqlParameter("@MaNV",nv_info.MaNV);
            para[1] = new SqlParameter("@TenNV", nv_info.TenNV);
            para[2] = new SqlParameter("@NgaySinh", nv_info.NgaySinh);
            para[3] = new SqlParameter("@Diachi", nv_info.DiaChi);
            para[4] = new SqlParameter("@SDT", nv_info.SDT);
            para[5] = new SqlParameter("@Email", nv_info.Email);
            para[6] = new SqlParameter("@ChucVu", nv_info.ChucVu);
            para[7] = new SqlParameter("@Phong", nv_info.Phong);
            return pd.Execute_Modify("NhanVien_Insert", para, CommandType.StoredProcedure);


        }
        public int NhanVien_Update(NhanVien_Info nv_info)
        {
            SqlParameter[] para = new SqlParameter[8];
            para[0] = new SqlParameter("@MaNV", nv_info.MaNV);
            para[1] = new SqlParameter("@TenNV", nv_info.TenNV);
            para[2] = new SqlParameter("@NgaySinh", nv_info.NgaySinh);
            para[3] = new SqlParameter("@Diachi", nv_info.DiaChi);
            para[4] = new SqlParameter("@SDT", nv_info.SDT);
            para[5] = new SqlParameter("@Email", nv_info.Email);
            para[6] = new SqlParameter("@ChucVu", nv_info.ChucVu);
            para[7] = new SqlParameter("@Phong", nv_info.Phong);
            return pd.Execute_Modify("NhanVien_Update", para, CommandType.StoredProcedure);


        }
        public int NhanVien_Delete(NhanVien_Info nv_info)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaNV",nv_info.MaNV);
         
            return pd.Execute_Modify("NhanVien_Delete", para, CommandType.StoredProcedure);


        }
        public DataTable NhanVien_TimTheoMaNV(string MaNV)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaNV", MaNV);

            return pd.Execute_Table("NhanVien_TimTheoMaNV", para, CommandType.StoredProcedure);
        }
        public DataTable NhanVien_TimTheoTen(string Ten)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@TenNV", Ten);

            return pd.Execute_Table("NhanVien_TimTheoTen", para, CommandType.StoredProcedure);
        }
        public DataTable NhanVien_TimTheoChucVu(string Chuvu)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@ChuVu", Chuvu);
            return pd.Execute_Table("NhanVien_TimTheoChuvu", para, CommandType.StoredProcedure);
        }
        public DataTable NhanVien_TimTheoPhong(string Phong)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@Phong", Phong);

            return pd.Execute_Table("NhanVien_TimTheoPhong", para, CommandType.StoredProcedure);
        }
       //load danh sach cac phong benh dieu tri
        public DataTable PhongDieuTri_All()
        {
            SqlParameter[] para = new SqlParameter[0];
            return pd.Execute_Table("PhongBenhDT_All", para, CommandType.StoredProcedure);
        }
       //load danh sach cac phong kham
        public DataTable PhongKham_All()
        {
            SqlParameter[] para = new SqlParameter[0];
            return pd.Execute_Table("PhongKham_All", para, CommandType.StoredProcedure);
        }


    }
}
